home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / forms_free.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  2.2 KB  |  78 lines

  1. //
  2. // "$Id: forms_free.cxx,v 1.4 1999/01/07 19:17:44 mike Exp $"
  3. //
  4. // Forms free widget routines for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. // Emulation of the Forms "free" widget.
  27. // This emulation allows the free demo to run, and has allowed
  28. // me to port several other programs, but it is in no way
  29. // complete.
  30.  
  31. #include <FL/Fl.H>
  32. #include <FL/Fl_Free.H>
  33.  
  34. void Fl_Free::step(void *v) {
  35.   Fl_Free *f = (Fl_Free *)v;
  36.   f->handle(FL_STEP);
  37.   Fl::add_timeout(.01,step,v);
  38. }
  39.  
  40. Fl_Free::Fl_Free(uchar t,int x,int y,int w,int h,const char *l,
  41.          FL_HANDLEPTR hdl) :
  42. Fl_Widget(x,y,w,h,l) {
  43.   type(t);
  44.   hfunc = hdl;
  45.   if (t == FL_SLEEPING_FREE) deactivate();
  46.   if (t == FL_CONTINUOUS_FREE || t == FL_ALL_FREE)
  47.     Fl::add_timeout(.01,step,this);
  48. }
  49.  
  50. Fl_Free::~Fl_Free() {
  51.   Fl::remove_timeout(step,this);
  52.   hfunc(this,FL_FREEMEM,0,0,0);
  53. }
  54.  
  55. void Fl_Free::draw() {hfunc(this,FL_DRAW,0,0,0);}
  56.  
  57. int Fl_Free::handle(int e) {
  58.   char key = Fl::event_key();
  59.   switch (e) {
  60.   case FL_FOCUS:
  61.     if (type()!=FL_INPUT_FREE && type()!=FL_ALL_FREE) return 0;
  62.     break;
  63.   case FL_PUSH:
  64.   case FL_DRAG:
  65.   case FL_RELEASE:
  66.     key = 4-Fl::event_button();
  67.     break;
  68.   case FL_SHORTCUT:
  69.     return 0;
  70.   }
  71.   if (hfunc(this, e, float(Fl::event_x()), float(Fl::event_y()), key)) do_callback();
  72.   return 1;
  73. }
  74.  
  75. //
  76. // End of "$Id: forms_free.cxx,v 1.4 1999/01/07 19:17:44 mike Exp $".
  77. //
  78.